package lib

func init() {
	Probs = append(Probs, Problem{
		Num:         367,
		Discription: "有效的完全平方数",
		Level:       1,
		Labels: map[string]int{
			"二分查找": 1,
		},
	})
}

func IsPerfectSquare(num int) bool {
	//1直接是true
	if num == 1 {
		return true
	}
    
	left := 1
	right := num / 2
	for left <= right {
		mid := (left + right) / 2
		if mid*mid == num {
			return true
		}

		if mid*mid < num {
			left = mid + 1
		} else {
			right = mid - 1
		}
	}

	return false
}